package utilities;

import java.io.*;

public class FileManager
{
    public static void serialize(Object o, String file)
    {
        FileOutputStream f = null;
	ObjectOutputStream out = null;
        
	try
	{
	    f = new FileOutputStream(file);
	    out = new ObjectOutputStream(f);
            
	    out.writeObject(o);
	}
	catch(Exception e){}
        finally
        {
            try
	    {
		if(out != null)
		    out.close();
		
		if(f != null)
		    f.close();
	    }
            catch(Exception e){}
        }
    }

    public static Object deserialize(String file)
    {
	FileInputStream f = null;
        ObjectInputStream in = null;
        Object o = null;

	try
	{
	    f = new FileInputStream(file);
            in = new ObjectInputStream(f);
            
            o = in.readObject();
	}
        catch(Exception e){}
        finally
        {
            try
	    {
		if(in != null)
		    in.close();
		
		if(f != null)
		    f.close();
	    }
            catch(Exception e){}
            
            return o;
        }
    }
}